<template>
  <div class="page">
    <div class="c-main p20">
      <div class="c-body">
        <el-row type="flex" justify="center">
          <el-col :span="14">
            <el-form ref="form" :model="pageAjax.data" label-width="120px">
              <el-form-item label="部门名称：">
                <el-input
                  placeholder="请输入部门名称"
                  v-model="pageAjax.data.name"
                  disabled
                ></el-input>
              </el-form-item>
              <el-form-item label="请选择上级部门">
                <el-cascader
                  disabled
                  v-model="pageAjax.data.parentId"
                  :props="orgCascaderCp.config.props"
                  :options="orgSupAjax.data"
                >
                </el-cascader>
              </el-form-item>
              <el-form-item>
                <el-button @click="rBack">取消</el-button>
              </el-form-item>
            </el-form>
          </el-col>
        </el-row>
      </div>
    </div>
  </div>
</template>
<script>
import { getDepartmentDetail } from "@/api/authority.js";

export default {
  name: "system_authorityOrganizationDetail",
  data: () => ({
    pageAjax: {
      btnDisabled: false,
      btnLoading: false,
      loading: false,
      data: {
        name: "", // 部门名称
        corpId: 1, // 所属公司
        parentId: 0, // 上级部门
        parentIds: 0,
        level: 0 // 级别
      }
    },
    orgSupAjax: {
      loading: false,
      data: [],
      orginData: []
    },

    orgCascaderCp: {
      config: {
        props: {
          value: "id",
          label: "name",
          checkStrictly: true
        }
      }
    }
  }),
  created() {
    let _that = this;

    _that.getOrgData();
    _that.getPageData();
  },
  methods: {
    getPageData() {
      let _that = this;

      getDepartmentDetail({ params: { id: _that.$route.query.id } })
        .then(resp => {
          let respData = resp.data || {};

          if (respData.code === _that.STATUS.success[0]) {
            _that.pageAjax.data = respData.data;
          } else {
            _that.$message.error(respData.msg || "获取失败");
          }
        })
        .finally(() => {});
    },
    getOrgData() {
      let _that = this;

      _that.$store.dispatch("getDepartmentList").then(() => {
        _that.orgSupAjax.data =
          _that.$store.getters.departmentListOffspringnTreeData;
      });
    },
    rBack() {
      this.$router.go(-1);
    }
  }
};
</script>
<style lang="scss" scoped>
.page {
  .s-search {
    border-bottom: 1px solid #eee;
  }
  .c-main {
    margin-top: 20px;
  }
  .c-pagination {
    margin-top: 20px;
    text-align: center;
  }
}
</style>
